-module(p1).
-export([result/0, main/1]).

result() -> main(1000).

main(Bound) ->
    sum_of_multiples(3, Bound) +
    sum_of_multiples(5, Bound) - 
    sum_of_multiples(15, Bound).

sum_of_multiples(Divisor, Bound) ->
    Count = (Bound - 1) div Divisor,
    Last = Count * Divisor,
    (Divisor + Last) * Count * 0.5.
